﻿namespace PropOnline.ViewModels.Propiedad
{
    using System;
    using System.Globalization;
    using PropOnline.Helpers;
    using PropOnline.Models;

    public class AvisoHistoriaViewModel
    {
        private string inmobiliaria;

        public DateTime Fecha { get; set; }

        public string FechaString
        {
            get
            {
                if (this.Fecha != null)
                {
                    return this.Fecha.ToString("dd/MM/yyyy", CultureInfo.CurrentCulture);
                }

                return string.Empty;
            }
        }

        public string Inmobiliaria
        {
            get
            {
                if (!string.IsNullOrEmpty(this.inmobiliaria))
                {
                    return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(this.inmobiliaria.ToLower(CultureInfo.CurrentCulture));
                }

                return "-";
            }

            set
            {
                this.inmobiliaria = value;
            }
        }

        public uint? Telefono { get; set; }

        public Moneda? Moneda { get; set; }

        public uint? Precio { get; set; }

        public string PrecioString
        {
            get
            {
                if (this.Precio > 0)
                {
                    var precio = this.Precio.Value.ToString("N0", CultureInfo.CurrentCulture);
                    var moneda = EnumExtensions.GetDescription(typeof(Moneda), this.Moneda);

                    return String.Format("{0} {1}", moneda, precio, CultureInfo.CurrentCulture);
                }

                return "-";
            }
        }

        public string TelefonoString
        {
            get
            {
                return PropiedadHelper.FormatTelefono(this.Telefono);
            }
        }

        public string Texto { get; set; }
    }
}